import { EnumChatState } from "@/api/siderBar/model"

export function useHRState(refetch: IFn) {
    const { state: collapsed, toggle: toggleCollased } = useSwitch(true)
    const hrStateMap = new Map<EnumChatState, string>([
        [EnumChatState.默认, "全部"],
        [EnumChatState.待介入, "待介入"],
        [EnumChatState.匹配成功, "匹配成功"],
        [EnumChatState.已约面, "已约面"],
        [EnumChatState.不合适, "不合适"]
    ])
    const hrStateOptions: IOption<EnumChatState>[] = [
        {value: EnumChatState.默认, label: hrStateMap.get(EnumChatState.默认)!},
        {value: EnumChatState.待介入, label: hrStateMap.get(EnumChatState.待介入)!},
        {value: EnumChatState.匹配成功, label: hrStateMap.get(EnumChatState.匹配成功)!},
        {value: EnumChatState.已约面, label: hrStateMap.get(EnumChatState.已约面)!},
        {value: EnumChatState.不合适, label: hrStateMap.get(EnumChatState.不合适)!}
    ]
    const {
        apply,
        handleItemTap: handleHrStateTap,
        selects: hrStateSelects,
    } = useOptionSelect({
        availableOptions: hrStateOptions,
        treatAll: false,
        mode: "single",
        rollbackSync: false,
        syncSelects() {
            apply()
            refetch()
        },
    })
    hrStateSelects.value.push(EnumChatState.默认)
    return {
        hrStateCollapsed: collapsed,
        toggleHrState: toggleCollased,
        handleHrStateTap,
        hrStateSelects,
        hrStateOptions,
        hrStateMap
    }
}